#! /bin/bash
server_array=(31 32 33 35 36 37)
ipadd=192.168.2
sudoerpw=yedpay
for server in ${server_array[*]}
do
echo "ssh to $server >>>"
ssh -Tq ubuntu@$ipadd.$server >/dev/null <<rmssh
cd /etc
echo $sudoerpw | sudo -S bash -c "echo '192.168.2.31	master31.maxidea.com'>> hosts"
echo $sudoerpw | sudo -S bash -c "echo '192.168.2.32    master32.maxidea.com'>> hosts"
echo $sudoerpw | sudo -S bash -c "echo '192.168.2.33    master33.maxidea.com'>> hosts"
echo $sudoerpw | sudo -S bash -c "echo '192.168.2.34    node34.maxidea.com'>> hosts"
echo $sudoerpw | sudo -S bash -c "echo '192.168.2.35    node35.maxidea.com'>> hosts"
echo $sudoerpw | sudo -S bash -c "echo '192.168.2.36    node36.maxidea.com'>> hosts"
rmssh
done
